{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "from manim import *\n",
    "import sympy as sy\n",
    "\n",
    "config.media_width = \"85%\"\n",
    "config.background_color = rgb_to_color(np.array([247, 203, 140])/255)\n",
    "# config.background_color = WHITE\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_gen = sy.numbered_symbols()\n",
    "x, y = sy.symbols(\"x y\")\n",
    "expr = x ** y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "class MainScene(Scene):\n",
    "    def construct(self):\n",
    "        n = 10\n",
    "        expr = x**y\n",
    "        expr_repr = MathTex(sy.latex(expr))\n",
    "        self.add(expr_repr)\n",
    "        for i in range(n):\n",
    "            expr = expr.subs(y, x**y)\n",
    "            expr_repr2 = MathTex(sy.latex(expr))\n",
    "            self.play(Transform(expr_repr, expr_repr2))\n",
    "\n",
    "\n",
    "class MainScene2(Scene):\n",
    "    def construct(self):\n",
    "        offset = 0.008\n",
    "        tip = Polygon([-offset, 0, 0], [offset, 0, 0], [0, 4, 0], stroke_width=0, fill_opacity=1, color=RED)\n",
    "\n",
    "        L = 7.5\n",
    "        l = L / 14\n",
    "        sw = 1\n",
    "        border = 0.01\n",
    "        plane = NumberPlane(\n",
    "            x_range=[-L / 2 - border, L / 2 + border, l],\n",
    "            y_range=[-L / 2 - border, L / 2 + border, l],\n",
    "            background_line_style={\n",
    "                \"stroke_color\": BLACK,\n",
    "                \"stroke_width\": sw,\n",
    "                \"stroke_opacity\": 1,\n",
    "            },\n",
    "            axis_config={\"color\": BLACK, \"stroke_width\": 0},\n",
    "        )\n",
    "        fixed_dots_r = 4 * border\n",
    "        fixed_dots = VGroup(*[Dot(radius=fixed_dots_r, color=BLACK) for _ in range(4)]).arrange_in_grid(\n",
    "            buff=l * 8 - 2 * fixed_dots_r\n",
    "        )\n",
    "        fixed_dots += Dot(radius=fixed_dots_r, color=BLACK)\n",
    "        self.add(plane, fixed_dots)\n",
    "        self.play(FadeIn(tip))\n",
    "        self.wait()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                   \r"
     ]
    },
    {
     "data": {
      "text/html": [
       "<video src=\"media\\jupyter\\MainScene2@2022-04-09@02-57-20.mp4\" controls autoplay loop style=\"max-width: 85%;\"  >\n",
       "      Your browser does not support the <code>video</code> element.\n",
       "    </video>"
      ],
      "text/plain": [
       "<IPython.core.display.Video object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%manim -v WARNING -qh MainScene2"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "2c0948b606a87f16a1329dbdb4c9bf2c1b73f2116240f6b736465dcfd150b23b"
  },
  "kernelspec": {
   "display_name": "Python 3.8.12 ('manim')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
